
import { connect } from 'react-redux' ;

import Dumb from '../views/cart';


function mapStateToProps(state) {
    return {
        items: state.cart.items
    }
}

function mapDispatchToProps(dispatch) {
    return {
        increase: id => {
            console.log( 'increase: ' , id );
            let action = {
                type: '增加',
                id
            }
            return dispatch(action);
        },
        decrease: id => {
            console.log( 'decrease: ' , id );
            let action = {
                type: '减少',
                id
            }
            return dispatch(action);
        }
    }
}

// 将UI组件(木偶组件)包裹成容器组件
const Cart = connect( mapStateToProps, mapDispatchToProps )( Dumb );

export default Cart;